package com.bp.hearthealth.pulse.lnapps.ads.topon.banner_ad

import android.content.Context
import com.anythink.banner.api.ATBannerExListener
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.ATNetworkConfirmInfo
import com.anythink.core.api.AdError
import com.bp.hearthealth.pulse.lnapps.bp_extension.LogUtil

class ATBannerExListenerImpl : ATBannerExListener {

    private var bnAdListener: TopOnBannerAdListener? = null

    fun setBannerLoadListener(bnAdListener: TopOnBannerAdListener?) {
        this.bnAdListener = bnAdListener
    }

    override fun onDeeplinkCallback(
        isRefresh: Boolean,
        adInfo: ATAdInfo,
        isSuccess: Boolean
    ) {
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onDeeplinkCallback:$adInfo--status:$isSuccess"
        )
    }

    override fun onDownloadConfirm(
        context: Context,
        adInfo: ATAdInfo,
        networkConfirmInfo: ATNetworkConfirmInfo
    ) {
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onDownloadConfirm:$adInfo networkConfirmInfo:$networkConfirmInfo"
        )
    }

    override fun onBannerLoaded() {
        bnAdListener?.onBannerLoaded()
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerLoaded"
        )
    }

    override fun onBannerFailed(adError: AdError) {
        bnAdListener?.onBannerFailed(adError)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerFailed: " + adError.fullErrorInfo
        )
    }

    override fun onBannerClicked(entity: ATAdInfo) {
        bnAdListener?.onBannerClicked(entity)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerClicked:$entity"
        )
    }

    override fun onBannerShow(entity: ATAdInfo) {
        bnAdListener?.onBannerShow(entity)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerShow 广告来源：${entity.networkName}"
        )
    }

    override fun onBannerClose(entity: ATAdInfo) {
        bnAdListener?.onBannerClose(entity)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerClose:$entity"
        )
    }

    override fun onBannerAutoRefreshed(entity: ATAdInfo) {
        bnAdListener?.onBannerAutoRefreshed(entity)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerAutoRefreshed:$entity"
        )
    }

    override fun onBannerAutoRefreshFail(adError: AdError) {
        bnAdListener?.onBannerAutoRefreshFail(adError)
        LogUtil.iTopOn(
            "TopOn 【Banner广告】 onBannerAutoRefreshFail: " + adError.fullErrorInfo
        )
    }
}